using Vwf.Tools;

namespace Vwf.Vwt {
	
	public class ParserMixed : Parser {
		protected BlockMixed myContent { get { return (BlockMixed)content; } }
		public override void parse() throws EDParser, EDStrParser {
			string cStart = strParser.createCursor();
			do {
				strParser.storeCursor(cStart);
				if (strParser.findAnyNext(new string[] { "?>", "<?" })) {
					add(new BlockHtml(strParser.substring(cStart)));
					strParser.toEndChunk();
					switch (strParser.lastChunk) {
						case "?>":
							logMsg("Konnec bloku ");
							strParser.toEndChunk();
							return;
						case "<?":
							logMsg("zjistuju dalsi parser ");
							var parser = getNextParser();
							parser.parse();
							add(parser.content);
							break;
					}
				} else {
					logMsg("Konnec textu ");
					break;
				};
			} while (true);
		}
		public ParserMixed() {
			content = new BlockMixed();
			blockTypes = new string[] {"h", "html"};
		}
		protected void add(Block item) {
			myContent.add(item);
		}
	}
}
